import { Component, OnInit, Input } from '@angular/core'
import { IAuditLog, ETaskOperationMap } from '@shared/interfaces/task'
import { ListBaseClass } from '@shared/classes/ListBaseClass'
import { NzMessageService } from 'ng-zorro-antd'
import { I18NService } from '@core'
import { Router, ActivatedRoute } from '@angular/router'
import { SettingsService } from '@delon/theme'
import { STColumn } from '@delon/abc'

@Component({
  selector: 'app-task-history-list',
  templateUrl: './history-list.component.html',
  styleUrls: ['../../../../../../shared/styles/table.less'],
})
export class TaskHistoryListComponent extends ListBaseClass<any, any> implements OnInit {

  @Input() auditLogs: IAuditLog[]
  columns: STColumn[] = []

  ETaskOperationMap = ETaskOperationMap

  constructor(
    public msg: NzMessageService,
    public i18n: I18NService,
    public router: Router,
    public route: ActivatedRoute,
    public settings: SettingsService,
  ) {
    super(msg, i18n, route, router, settings)
  }

  ngOnInit() {
    this.hideStPage()
    this.initColumns()
    this.data = this.auditLogs
  }

  hideStPage(): void {
    this.stPage = {
      show: false,
      front: false,
      total: false,
      showQuickJumper: false,
    }
  }

  initColumns(): void {
    this.columns = [
      {
        title: '操作时间',
        i18n: 'GENERAL.INFO.OPERATED_AT',
        index: 'createTime',
        width: '200px',
        type: 'date',
        className: 'text-center',
      },
      {
        title: '操作用户',
        i18n: 'GENERAL.INFO.OPERATOR',
        index: 'operator',
        width: '100px',
        className: 'text-center',
      },
      {
        title: '操作内容',
        i18n: 'GENERAL.INFO.OPERATION_TIPS',
        index: 'auditOperation',
        width: '200px',
        className: 'text-center',
        render: 'operation',
      },
      {
        title: '备注',
        i18n: 'GENERAL.INFO.REMARK',
        index: 'remark',
        width: '200px',
        className: 'text-left',
      }
    ]
  }
}
